<template>
    <div>
        <el-row :gutter="10" type="flex" justify="space-around">
            <el-col :xs="24" :sm="12" :md="8" :lg="8">
                <el-button type="primary" plain icon="el-icon-s-order" size="mini" @click="openSysAttachmentDialog">附件</el-button>
            </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="8" class="formTitle">{{ title }}</el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="8" style="text-align: right;padding-right: 20px;">
                <el-button type="primary" v-if="util.isEmpty(readonly) ? (util.isEmpty(taskId) && util.isEmpty(flowInsId))  :  !(readonly=='1') " plain icon="el-icon-check" size="mini" @click="submitForm('0')">保存</el-button>
                <el-button type="primary" v-if="!util.isEmpty(taskId)" plain icon="el-icon-check" size="mini" @click="commitTask()">同意</el-button>
                <el-button type="warning" v-if="!util.isEmpty(taskId)" plain icon="el-icon-close" size="mini" @click="reject()">驳回</el-button>
                <el-button type="primary" v-if="!util.isEmpty(flowInsId)" plain icon="el-icon-check" size="mini" @click="showFlowInfoDialog('1')">流程信息</el-button>
            </el-col>
        </el-row>

        <!--    流程信息    -->
<!--        <FlowInfo :businessId="businessId+''" :billType="billType" v-if="showFlowInfo" :showStatus="showFlowInfo" @closeFlowInfoDialog="closeFlowInfoDialog"></FlowInfo>-->
        <!--   办理任务弹窗     -->
        <ConfirmCommitTask :taskId="taskId" :insId="flowInsId" @closeCommitDialog="closeCommitDialog" :commitType="commitType" :showStatus="showCommitDialog"></ConfirmCommitTask>
        <!--   单据附件弹窗     -->
        <FormAttachment :businessId="businessId" :billType="billType" v-if="showSysAttachmentDialog" :showStatus="showSysAttachmentDialog"
                        :readonly="util.isEmpty(readonly) ? (!(util.isEmpty(taskId) && util.isEmpty(flowInsId)))  :  (readonly=='1')"
                        @closeSysAttachmentDialog="closeSysAttachmentDialog"></FormAttachment>
    </div>
</template>
<script>
//import FlowInfo from "@/views/oa/flow/flowInfo";
import FormTopBar from "@/views/common/formTopBar"
import FormAttachment from "@/views/common/sysAttachment/formAttachment"

export default {
    name: "formTopBar",
    //components:{FlowInfo,FormTopBar,FormAttachment},
    components:{FormTopBar,FormAttachment},
    props: {
        title:"",
        taskId:"",
        flowInsId: "",
        billType: "",
        businessId:"",
        readonly:""
    },
    created() {
        console.log("顶部按钮条："+this.billType+","+this.taskId+","+this.flowInsId);
    },
    data() {
        return {
            commitType:"",
            showCommitDialog:false,
            showSysAttachmentDialog:false,
            showFlowInfo:false,
            openBusAttachmentDialog:false
        }

    },
    methods:{
        //根据实例获取流程图片--打开流程信息
        showFlowInfoDialog(){
            this.showFlowInfo = true;
        },
        //关闭流程信息窗口
        closeFlowInfoDialog(){
            this.showFlowInfo = false;
        },
        //提交审批
        commitTask(){
            this.commitType = "agree";
            this.showCommitDialog = true;
        },
        //驳回申请
        reject(){
            this.commitType = "reject";
            this.showCommitDialog = true;
        },
        //关闭完成任务弹窗
        closeCommitDialog(){
            this.showCommitDialog = false;
        },
        //打开附件窗口
        openSysAttachmentDialog(){
            if(!this.businessId){
                this.$modal.msgError("请先【保存】单据！再进行附件上传！");
                return;
            }
            this.showSysAttachmentDialog = true;
        },
        //关闭附件窗口
        closeSysAttachmentDialog(){
            this.showSysAttachmentDialog = false;
        },
        //保存
        submitForm(){
            this.$emit("submitForm");
        }
    }
}
</script>
